﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpShare.Afp.Protocol.Handlers {
    public enum AfpZzzzFlags : uint {
        GoingToSleep = 1,
        WakingUp = 2
    }

    internal class AfpZzzzRequestHandler : IAfpRequestHandler {
        #region IAfpRequestHandler Members

        public byte CommandCode {
            get { return 122; }
        }

        public AfpResultCode Process(IAfpSession session, DsiHeader dsiHeader, AfpStream requestStream, AfpStream responseStream) {
            requestStream.ReadPadding();

            AfpZzzzFlags flags = requestStream.ReadEnum<AfpZzzzFlags>();

            switch (flags) {
                case AfpZzzzFlags.GoingToSleep:
                    session.IsSleeping = true;
                    break;
                case AfpZzzzFlags.WakingUp:
                    session.IsSleeping = false;
                    break;
                default:
                    return AfpResultCode.FPParamErr;
            }

            return AfpResultCode.FPNoErr;
        }

        #endregion
    }
}
